package uit.compile.lexical;

public class Token {
    public static final int AND = 0;
    public static final int ARRAY = 1;
    public static final int BEGIN = 2;
    public static final int CONST = 3;
    public static final int DIV = 4;
    public static final int DO = 5;
    public static final int DOWNTO = 6;
    public static final int ELSE = 7;
    public static final int END = 8;
    public static final int FOR = 9;
    public static final int FUNCTION = 10;
    public static final int IF = 11;
    public static final int MOD = 12;
    public static final int NOT = 13;
    public static final int OF = 14;
    public static final int OR = 15;
    public static final int PROCEDURE = 16;
    public static final int PROGRAM = 17;
    public static final int REPEAT = 18;
    public static final int THEN = 20;
    public static final int TO = 21;
    public static final int UNTIL = 22;
    public static final int VAR = 23;
    public static final int WHILE = 24;
    public static final int ADDOP = 25;//+ OR -
    public static final int MULOP = 26;//* OR /
    public static final int EQOP = 27;//= 
    public static final int ASSIGNOP = 28;//:=
    public static final int RELOP = 29;//< OR > OR <= OR >= OR <>
    public static final int RIGHTPAR = 32; //)
    public static final int LEFTPAR = 33; //(
    public static final int RIGHTSQURBRK = 34; //]
    public static final int LEFTSQURBRK = 35; //[
    public static final int COMMA = 36;//,
    public static final int COLON = 37;//:
    public static final int SEMICOLON = 38;//;
    public static final int RANGE = 39;//..
    public static final int INTLITERAL = 40;
    public static final int REALLITERAL = 41;
    public static final int STRINGLITERAL = 42;
    public static final int BOOLEANLITERAL = 43; //true or false    
    public static final int EOF = 44; //$
    public static final int ERROR = 45; //Error
    public static final int ID = 46; //Identifier
    public static final int DOT = 47; //.
    public static final int INTEGER = 48; //integer
    public static final int REAL = 49; //real
    public static final int BOOLEAN = 50; //boolean
    public static final int BREAK = 51; //break
    public static final int CONTINUE = 52; //continue
 
    public int Kind; //kind of Token (e.g. Token.INTLITERAL, Token.ADDOP...)
    public String Lexeme; // holds the lexeme of token (e.g. 'abcde', 123.54, for...)
    public SourcePosition position; //holds the position of Token (see details in class SourcePosition)

    public Token() {
        Kind = -1;
        Lexeme = null;
        position = new SourcePosition();
    }

    public Token(int kind) {
        Kind = kind;
        Lexeme = null;
        position = new SourcePosition();

    }

    public Token(int kind, String lexeme) {
        Kind = kind;
        Lexeme = lexeme;
        position = new SourcePosition();
    }

    public Token(int kind, String lexeme, SourcePosition p) {
        Kind = kind;
        Lexeme = lexeme;
        position = new SourcePosition(p);
    }

    public static String toString(int i) {
        if (i == Token.AND) {
            return "Token.AND";
        } else if (i == Token.ARRAY) {
            return "Token.ARRAY";
        } else if (i == Token.BEGIN) {
            return "Token.BEGIN";
        } else if (i == Token.CONST) {
            return "Token.CONST";
        } else if (i == Token.DIV) {
            return "Token.DIV";
        } else if (i == Token.DO) {
            return "Token.DO";
        } else if (i == Token.DOWNTO) {
            return "Token.DOWNTO";
        } else if (i == Token.ELSE) {
            return "Token.ELSE";
        } else if (i == Token.END) {
            return "Token.END";
        } else if (i == Token.FOR) {
            return "Token.FOR";
        } else if (i == Token.FUNCTION) {
            return "Token.FUNCTION";
        } else if (i == Token.IF) {
            return "Token.IF";
        } else if (i == Token.MOD) {
            return "Token.MOD";
        } else if (i == Token.NOT) {
            return "Token.NOT";
        } else if (i == Token.OF) {
            return "Token.OF";
        } else if (i == Token.OR) {
            return "Token.OR";
        } else if (i == Token.PROCEDURE) {
            return "Token.PROCEDURE";
        } else if (i == Token.PROGRAM) {
            return "Token.PROGRAM";
        } else if (i == Token.REPEAT) {
            return "Token.REPEAT";
        } else if (i == Token.THEN) {
            return "Token.THEN";
        } else if (i == Token.TO) {
            return "Token.TO";
        } else if (i == Token.UNTIL) {
            return "Token.UNTIL";
        } else if (i == Token.VAR) {
            return "Token.VAR";
        } else if (i == Token.WHILE) {
            return "Token.WHILE";
        } else if (i == Token.ADDOP) {
            return "Token.ADDOP";
        } else if (i == Token.MULOP) {
            return "Token.MULOP";
        } else if (i == Token.EQOP) {
            return "Token.EQOP";
        } else if (i == Token.ASSIGNOP) {
            return "Token.ASSIGNOP";
        } else if (i == Token.RELOP) {
            return "Token.RELOP";
        } else if (i == Token.RIGHTPAR) {
            return "Token.RIGHTPAR";
        } else if (i == Token.LEFTPAR) {
            return "Token.LEFTPAR";
        } else if (i == Token.RIGHTSQURBRK) {
            return "Token.RIGHTSQURBRK";
        } else if (i == Token.LEFTSQURBRK) {
            return "Token.LEFTSQURBRK";
        } else if (i == Token.COMMA) {
            return "Token.COMMA";
        } else if (i == Token.COLON) {
            return "Token.COLON";
        } else if (i == Token.SEMICOLON) {
            return "Token.SEMICOLON";
        } else if (i == Token.RANGE) {
            return "Token.RANGE";
        } else if (i == Token.INTLITERAL) {
            return "Token.INTLITERAL";
        } else if (i == Token.REALLITERAL) {
            return "Token.REALLITERAL";
        } else if (i == Token.BOOLEANLITERAL) {
            return "Token.BOOLEANLITERAL";
        } else if (i == Token.STRINGLITERAL) {
            return "Token.STRINGLITERAL";
        } else if (i == Token.EOF) {
            return "Token.EOF";
        } else if (i == Token.ID) {
            return "Token.ID";
        } else if (i == Token.DOT) {
            return "Token.DOT";
        } else if (i == Token.INTEGER) {
            return "Token.INTEGER";
        } else if (i == Token.REAL) {
            return "Token.REAL";
        } else if (i == Token.BOOLEAN) {
            return "Token.BOOLEAN";
        } else if (i == Token.BREAK) {
            return "Token.BREAK";
        } else if (i == Token.CONTINUE) {
            return "Token.CONTINUE";
        } else if (i == Token.ERROR) {
            return "Token.ERROR";
        }
        else {
            return "ERROR";
        }
    }

    public String toString() {
         return Token.toString(Kind) + "\tLexeme:" + Lexeme + "\t" + position.toString();
    }
}
